package com.zuijin.demo.controller;

import jakarta.servlet.http.HttpServletRequest;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 *  测试接口
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @since 2024-12-30 14:46
 */
@RestController
@RequestMapping("/test")
public class TestController {
    @GetMapping("/t1")
    public String t1(HttpServletRequest request) {
        String[] ids = request.getParameterValues("id");
        return String.join(",", ids);
    }

    @GetMapping("/t2")
    public String t2(@RequestParam(value = "ids", required = false) String[] ids) {
        return String.join(",", ids);
    }

    @Data
    public static class Test {
        String[] ids;
        List<String> names;
        String age;
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        Date birthday;
    }
    @GetMapping("/t3")
    public Test t3(Test test) {
        return test;
    }
}
